{extend name="public:_base" /}
{block name="css"}
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadify/uploadify.css">
{/block}
{block name="js"}
{include file="public/_validform"}

<script type="text/javascript">
    var array = [{$data.rules ?? ''}];
    for (var k = 0, length = array.length; k < length; k++) {
        $("[name='rules_id[]'][value=\'" + array[k] + "\']").attr("checked", true);
    }
	
	function checkAll(obj) {
		$(obj).parents('.b-group').eq(0).find("input[type='checkbox']").prop('checked', $(obj).prop('checked'));
	}
</script>
{/block}
{block name="main"}

<div class="page-container">
    
    <form action="{:url(\''.\\think\\Request::instance()->controller().'/save')}" method="post" class="form form-horizontal" id="form">

        <table class="table table-border table-bordered table-bg table-style">
            <thead>
                <tr>
                    <th colspan="2" scope="col">填写信息</th>
                </tr>
            </thead>
            
            <tbody>
                <tr>
                    <th>
                        角色：
                    <td>
                        <input type="text" class="input-text" value="{$data.title ?? ''}" placeholder="" name="title">
                    </td>
                </tr>

                <tr>
                    <th>
                        权限节点：
                    </th>
                    <td>
                        <table class="layui-table">
                            <thead>
                                <tr class="text-c">
                                    <th ><input name="nav1" type="checkbox">所有节点</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="text-c">
                                    <td>
										<table class="layui-table">
										
										 {foreach name="auth_rule" item="v"}
                            {empty name="v['child']"}
                                <tr class="b-group">
                                    <th width="10%">
                                        <label>
                                            {$v['title']}
                                            <input type="checkbox" name="rules_id[]" value="{$v['id']}"   onclick="checkAll(this)" >
                                        </label>
                                    </th>
                                    <td></td>
                                </tr>
                                {else /}
                                <tr class="b-group">
                                    <th width="10%">
                                        <label>
                                            {$v['title']}
                                            <input type="checkbox" name="rules_id[]" value="{$v['id']}"  onclick="checkAll(this)">
                                        </label>
                                    </th>
                                    <td class="b-child">
                                        {foreach name="v['child']" item="n"}
                                            <table class="table table-border table-bordered table-bg table-style">
                                                <tr class="b-group">
                                                    <th width="10%">
                                                        <label>
                                                            {$n['title']}
                                                            <input type="checkbox" name="rules_id[]" value="{$n['id']}"  onclick="checkAll(this)">
                                                        </label>
                                                    </th>
                                                    <td class="bs-group">
                                                        {notempty name="n['child']"}
                                                            {volist name="n['child']" id="c"}
                                                                <label>
                                                                    &emsp;{$c['title']} <input type="checkbox" name="rules_id[]" value="{$c['id']}" >
                                                                </label>
                                                            {/volist}					
                                                        {/notempty}
                                                    </td>
                                                </tr>
                                            </table>
                                        {/foreach}
                                    </td>
                                </tr>
                           {/empty}
                        {/foreach}
						</table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
            
            <tfoot>
                <tr>
                    <td colspan="2" >
                        {:token()}
                        <input type="hidden" value="{$data.id ?? ''}" name="id">
                        
                        <input class="btn radius btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                        <input class="btn radius btn-default radius" type="reset" value="&nbsp;&nbsp;重置&nbsp;&nbsp;">
                        <!-- <button onClick="layer_close();" class="btn radius btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button> -->
                    </td>
                </tr>
            </tfoot>
            
        </table>

    </form>
</div>
{/block}
